<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>注册</title>
	</head>
	<link rel="stylesheet" href="../../libs/css/zhuce.css" />
	<link rel="stylesheet" href="../../css/index.css" />
	<script type="text/javascript" src="../../libs/js/vue.min.js"></script>
	<script type="text/javascript" src="../../libs/js/vant.min.js"></script>
	<script type="text/javascript" src="../../libs/js/ajax.js"></script>
	<script type="text/javascript" src="../../libs/js/return.js"></script>

	</head>
	<script type="text/javascript">
		document.addEventListener('plusready', function() {
			//console.log("所有plus api都应该在此事件发生后调用，否则会出现plus is undefined。"
		});
	</script>

	<body>
		<div id="appzhu">
			<div id="">
				<van-nav-bar title="注册" left-text="返回" left-arrow @click-left="onClickLeft">
			</div>
			<van-cell-group>
				<van-field v-model="phone" placeholder="请输入手机号" error-message=""></van-field>
				<van-cell-group>
					<van-field v-model="sms" center clearable placeholder="6位短信验证码">
						<van-button slot="button" @click="getverify" size="small" type="danger">发送验证码</van-button>
					</van-field>
				</van-cell-group>
				<van-field v-model="password" placeholder="登录密码(最少6位)"></van-field>
				<van-field v-model="confirmpassword" type="password" placeholder="确认密码(再次输入登陆密码)"></van-field>
				<van-field v-model="username" placeholder="昵称(最多20个字)"></van-field>
			</van-cell-group>
			<center style="font-size: 12px;margin-top: 20px;">注册会员及表示同意
				<a style="color:#8000FF ;">《美队用户注册协议》</a>
			</center>
			<van-row style="margin-top: 20px;">
				<van-col span="20" offset="2">
					<van-button size="large" type="danger" @click="registerClick">立即注册</van-button>
				</van-col>
			</van-row>
		</div>
		<script type="text/javascript">
			var vm = new Vue({
				el: "#appzhu",
				data: {
					phone: "",
					disabled: false, //发送验证码信息的按钮
					sms: "",
					password: "",
					confirmpassword: "",
					username: "",
					districtCode: "410522",
					getyzm: "",
				},
				methods: {
					onClickLeft: function() {
						var ws = plus.webview.currentWebview();
						plus.webview.close(ws);
					},
					getverify: function() { //获得验证码							
						var _this = this;
						ajax({
							url: "http://dsapi.ysd3g.com/API/SendRegisterPhoneCode",
							dataType: "jsonp",
							data: {
								phone: _this.phone
							},
							success: function(res) {
								console.log(res);
								if(res.Error == false) {
									//alert(res.Code);
									vm.$toast.fail(res.Code);
									_this.getyzm = res.Code;
									console.log(_this.getyzm)
								} else if(res.Error == true) {
									alert(res.Msg);
									return;
								}
							}
						})
					},
					registerClick: function() { //立即注册
						//alert(this.phone);
						ajax({
							dataType: "jsonp",
							url: "http://dsapi.ysd3g.com/API/UserRegister",
							data: {
								phone: this.phone,
								code: this.getyzm,
								password: this.password,
								districtCode: this.districtCode,
								nickName: this.username,
							},
							success: function(res) {
								if(res) {
									alert("恭喜注册成功");
									console.log(res)
								} else {
									alert("注册失败")
									console.log(res)
								}
							}
						})
					},
				}
			})
		</script>
	</body>

</html>